package logic

import (
	"context"
	"srv/srv"

	"api/internal/svc"
	"api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type AdmListHouseLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewAdmListHouseLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AdmListHouseLogic {
	return &AdmListHouseLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *AdmListHouseLogic) AdmListHouse(req *types.AdmListHouseRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line

	house, err := l.svcCtx.Srv.AdmListHouse(l.ctx, &srv.AdmListHouseRequest{
		HouseStatus: req.HouseStatus,
		Page:        req.Page,
		Size:        req.Size,
		StartPricer: req.StartPricer,
		EndPricer:   req.EndPricer,
	})
	if err != nil {
		return nil, err
	}

	if err != nil {
		return &types.Response{
			Code: 500,
			Msg:  err.Error(),
			Data: nil,
		}, nil

	}

	return &types.Response{
		Code: 200,
		Msg:  "管理员房源列表展示成功",
		Data: map[string]interface{}{
			"List":  house.List,
			"count": house.Count,
		},
	}, nil
}
